/******************************************************************************
copyright(c)cguage.com
source code can be free to use and publish, but please keep header comments, thx

author:  cguage
contact: tangcraig@gmail.com
desc:    missing
date:    unknown

*******************************************************************************/
#pragma once

class AutoShutdown : public Job {
protected:
    string name() {return "AutoShutdown";}

    void onInit() {
    }

    void run(const string& strParams) {
        time_t t = time(0);
        tm inf;
        localtime_s(&inf, &t);

        if (inf.tm_wday >= 1 && inf.tm_wday <= 4) { // Monday - Thursday
            // warning every some minutes
            if (2 == inf.tm_hour && inf.tm_min % 5 && 0 == inf.tm_sec) {
                InfoWnd::instance()->showText(loadResString(IDS_SHUTDOWN));
            }   

            // do task
            if (inf.tm_hour >= 2 && inf.tm_min > 30
            &&  inf.tm_hour <= 6 && inf.tm_min <= 1) {     // 2:30 - 6:00
                cout << "shutting down....." << endl;
                system("rundll32.exe powrProf.dll,SetSuspendState");
            }
        }
    }

private:
    Timer _timer;
} ;//_end_AutoShutdown;